package com.alipay.api.test.fsf;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradeQueryRequest;
import com.alipay.api.response.AlipayTradeQueryResponse;

/** 
 * 根据订单号或则支付宝交易帐号   查询单张订单详情
 *  @author fangshufeng  2018年2月8日
 */
public class BillDownOne {
	
	// 初始化实例请求对象
	public static String APP_ID = "2016091200495918"; // 自己的商户appid
	// RSA签名方式使用算法：SHA1withRSA。 注意此处是RSA 的私钥 是Java版本格式的 如果是用.NET 就要转换为.NET版本的格式
	public static String APP_PRIVATE_KEY = "MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCXFPoT2ozxE8X3onHpEW+nXA9JOZZdNpbprRu9+XOXuq6b3mHf2qMe+LfHH+1vMAdXzIrugRpa6OedxfuWUyF5PEFFfGV//5NoyA/II5/scmxVFo+75pjLnYqg8tPAhDiiRF7iTi/9OZbLRmpUulCQfUQ37gRQlRZXT8/mMuM9X2EcbNDf749y/z/G+U0GX9jOPW/AHqekxbfXLkzS6avqo/Sqg8Sa0SnafkyOyQAPVPy2uBJFcTStrmTcyrG1+HC3HPEMsOXUBtM+GveefE/np3+uFloIQeaV9Rg6PPBDBgiD30ALdVbhkDdV7oBAGB1zFtXZ3WQhNK8eaSFk0I8jAgMBAAECggEBAIM7J1XjepVVFZpaMhO+n3uBzY1PRjrFViS3xucnLK7Y6x5c9isZoKMga5G9O+Jel6I9+1fcMGZS9AzpkfUrVGIYYqHWwduCxio3zO2NdDZP1aW7KTKPxJzoxSe0hRYuQ3s/ZCOywqB0S3VaPrZF+ADprj3es0TDm1pP60gLX7NINWeJicnGP8LjidYZsI3kDacRxwVSA1Lfsp8cL+lZYsfJgfSZABDYuN1tdIv2rCrs6Rz3LbjRCvbuwIs6pSakjfqCwizNEwvYrBg4KO7GKmNeY9qvf3Ii/Y/tkR5QctWBTpweJA6K8M3/0i5g7Im2AT8INCUsB0eGKqScSnDhfeECgYEA02vp5sY/sCMleEcYGgMy0whDintipkLmIjXARcy8oh2UV8NRjPKpl4Y9ID9EQ1ELZt6pkjgslh7FfaUcxqe3A/we8YA7iOWdDM6n+alt+EvgsdnBRCFnjt43XFkZSO/qp5/B0lVwO9ZAi/kQSG7p89vylUU3a91E7TE49iFAGysCgYEAtvAPR6kP8yE/Cn1M7ZRf2bcMZ7SZSP+k0/4FUCqfkak+u/yCCZAHXWp8lFbhFFbHMnyBCZJ3u+f9K1kfihM9WPvIWFvUntz3QMvoYNWkwT8myK4Qs9u+QVz57UszNVL/lgo82nAhjEtInf8gT9HRA9HCQ8/2vnrm9eQgen84/+kCgYBni2WN6bBNcpkqVB9gtgpRQq3Zh95jsUYGoS6ewMvt1fDOHtG05y/aDxumzHWBRpL/+bMw8qQbjcyJYbE7Ne6zW+pHutbtkA8fs6Ke6rT6MydD03MNDBMs7HZOmzCAAUh6egqyGbgTBjaslvm7j96y2RjwtGqVQFQ+mqncGaLM6wKBgEtKoC9RMKRTUZvimC/L+msjwHJKTTBTLyalDNDCyivsKUq7kVWYNr/G3QE8hKSXVqK7xWwIIUlwIK2fn7B3XK9r6Tgci3Ta4tSDV9/K7mUutaqwoWU1EqfaOW7lnWzb/R9mlUceEWCpd3i3kTfo1gqpYTgBtr8M3FPlkUx5Yh9JAoGAF5bERRbaJf7/C3PSonDXL0af0iHse0F0yOlrp8B0Sgb2hcgYTAG6icX4KPT5sNQ58MCLpLFNkLC3etljSvjJWX+JQ0m0C0PyIVoePltuzfNVz2to8JJqAvE2QFDkWT+vd/d9uc6k0wr8yJBBzE4IDFBY/+MTZpDlSdXO8swwI8Y=";

	// RSA2签名方式使用算法：SHA256withRSA。
	// public static String APP_PRIVATE_KEY ="+zA3RJzhtiL4MIHks4GD++6RuQ/";

	// 公钥是可以公用的在公共平台配置的 .NET和Java语言的都可以共用。但是要区别 RSA或者是RSA2的公钥签名
	public static String ALIPAY_PUBLIC_KEY = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAlxT6E9qM8RPF96Jx6RFvp1wPSTmWXTaW6a0bvflzl7qum95h39qjHvi3xx/tbzAHV8yK7oEaWujnncX7llMheTxBRXxlf/+TaMgPyCOf7HJsVRaPu+aYy52KoPLTwIQ4okRe4k4v/TmWy0ZqVLpQkH1EN+4EUJUWV0/P5jLjPV9hHGzQ3++Pcv8/xvlNBl/Yzj1vwB6npMW31y5M0umr6qP0qoPEmtEp2n5MjskAD1T8trgSRXE0ra5k3MqxtfhwtxzxDLDl1AbTPhr3nnxP56d/rhZaCEHmlfUYOjzwQwYIg99AC3VW4ZA3Ve6AQBgdcxbV2d1kITSvHmkhZNCPIwIDAQAB";

	public static void main(String[] args) throws Exception {
		AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipaydev.com/gateway.do",APP_ID,APP_PRIVATE_KEY,"json","GBK",ALIPAY_PUBLIC_KEY,"RSA2");
		AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
		request.setBizContent("{" +
		"\"out_trade_no\":\"20150320010101001\"," +
		"\"trade_no\":\"2014112611001004680073956707\"" +
		"}");
		AlipayTradeQueryResponse response = alipayClient.execute(request);
		if(response.isSuccess()){
		System.out.println("调用成功");
		} else {
		System.out.println("调用失败");
		}
	}
}
